<template>
<view class="page flex_c" style="height: 100vh">
  <nav-bar text-center title="我的关注" />
  <view class="flex1" style="overflow: hidden">
    <scroll-view scroll-y style="height: 100%" lower-threshold="100" @scrolltolower="onLoad" refresher-enabled
      :refresher-triggered="triggered" @refresherrefresh="onRefresh">
      <div class="flex_b_c p-20 flex_wrap  gap-12">
        <navigator :url="`/pages/ipElite/infomation?id=${item.vipUserInfo.id}`" hover-class="none" v-for="(item, idx) in list" :key="item.id">
          <ipElite :item="item.vipUserInfo">
            <template #opt></template>
          </ipElite>
        </navigator>
      </div>
      <van-empty v-if="total === 0" class="pt-60" image="https://zsjl.oss-cn-beijing.aliyuncs.com/test/xcx/empty.png"
        description="暂无关注" />
      <view v-if="total && total === list.length" class="all_tip">到底了</view>
    </scroll-view>
  </view>
</view>
</template>
<script setup>
import ipElite from "@/components/ipElite/list-card"
import { ref, reactive, toRefs, onBeforeMount } from 'vue'
import { onShow } from '@dcloudio/uni-app'

import {
  getCollectList, // 列表
} from '@/api/center'
let form = reactive({
  collectType: 5,  // 0：作品；1：项目；2：作品征集；3：项目征集 4：交易 5：IP精英收藏 6:话题收藏 7.剧本征集 8.小说征集 9.拍摄征集 10.招募
  pageCode: 1,
  pageSize: 40
})
onShow(() => {
  data.list = []
  form.pageCode = 1
  fnGet()
})
let data = reactive({
  list: [],
  total: '',
  triggered: false
})
let fnGet = async () => {
  const { code, data: { total, rows } } = await getCollectList(form)
  if (code === 200) {
    data.list = data.list.concat(rows)
    data.total = total
    data.triggered = false
  }
}
let onLoad = e => {
  if (data.total > data.list.length) {
    ++form.pageCode
    fnGet()
  }
}
let onRefresh = () => {
  form.pageCode = 1
  data.list = []
  data.triggered = true
  fnGet()
}
let { total, list, triggered } = toRefs(data)


</script>